home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / ExtremeAmos / Text / R_DRAW_Buttons.ASC < prev    next >
Text File  |  1995-12-30  |  5KB  |  94 lines

  1. ü
  2.                              DRAW button tutorial
  3.                              ~~~~~~~~~~~~~~~~~~~~
  4. ù
  5.         You would not believe how usefull a DRAW button routine can be if
  6.     you have never used one before. In the old times, you had to use lot's
  7.     of different sprites, or have a next screen with the depression of a
  8.     key you can press, but a DRAW command totally eliminates this, and is
  9.     a whole lot faster, and less memory consuming.
  10.     
  11. ý
  12.         Try to imagine a screen such as directory opus. The different
  13.     buttons on that are drawn using a DRAW button routine, otherwise there
  14.     would be loads of sprites in memory, taking up even more sprites that 
  15.     what are already used. But, with 4 DRAW commands in AMOS, I can change 
  16.     ANY of the buttons, no matter what the size, to any colour or shape.
  17.     
  18. ø
  19.         How do you do this, I hear you ask. One way is to draw solid line
  20.     boxes on a screen using Dpaint, and add all the text etc. that you
  21.     want to have printed, so that you can make a perfect size estimation
  22.     of where you want all of the different buttons to go. The next step is
  23.     to jot down all the top-left and bottom-right hand coordinates on a
  24.     pad, so that you can enter them into the AMOS program a bit later. You
  25. ÿ
  26. ø
  27.     can then erase all of the box lines, and just Spack the background
  28.     that is left into memory, which should make the size of the compressed
  29.     picture a little smaller.
  30.     
  31. û
  32.         As you see this issue running, the borders surrounding each of the
  33.     icons are all done using the same DRAW routine, as is the windows and
  34.     borders used. This saves me a lot of time and memory when compiled. I
  35.     can also change the size and shape of any of the borders without
  36.     having to worry too much about the memory being used, if I had used a
  37.     bob or icon.
  38.     
  39. ý
  40.         All the coordinates are placed into 4 arrays. In this case, we
  41.     will use A, B, C, and D. As a default, I normally set the number of 
  42.     elements to 200 (to allow 200 buttons to be stored in mem), but when a 
  43.     program is finished, I cut it down to the correct size, so that I can 
  44.     grab those extra few bytes back. A and B represent the top left-hand 
  45.     corner of the box, whereas C and D represent the bottom right. These 
  46.     are the pixels on the screen to be used by the DRAW routine, and can 
  47.     also be used for other tings, such as clearing the appropriate box off 
  48.     the screen, or to place a ZONE around it for detection via the mouse, 
  49. ÿ
  50. ý
  51.     plus loads more other things.
  52.     
  53. ù
  54.         The DRAW routine is extremely simple. You could simple use a Box
  55.     A(no.),B(no.) To C(no.),D(no.) command, which would simply draw a solid
  56.     lined box around the area, in one colour. In order to get the
  57.     different height effect, we use 2 colours, normally white and black,
  58.     which when inversed around, appear to be either indented or standing
  59.     out from the paper. It is always a good idea to have a second colour
  60.     black in the palette, as sprites and blocks are always affected by the
  61.     transparancy of colour 0. The first 2 DRAW statements are called to
  62.     the top left-hand corner, to the bottom left hand cornar, joining at
  63.     the bottom right corner, with the other 2 changing colour and although
  64.     joining at the same ends, takes route via the top right hand corner
  65.     instead. Simple. Because you can alter the colours of each direction,
  66.     you re-create the effect of having "Pressed" on the button.
  67.     
  68. ø
  69.         An example here would be a waste of time, so in the SOURCE section
  70.     on disk 2, there is a small program labelled "AK_Buttons.AMOS", which
  71.     I tore out from one of my module players, which demonstrates how
  72.     simple and effective the routines can be. The program it was taken
  73. ÿ
  74. ø
  75.     from is MMPlay GUI, a module player which I am still working on, which
  76.     plays any Sound/Pro/Noisetracker modules, along with any AMOS Tracker
  77.     or music banks, and also MED modules (MMD0 and MMD1). Features
  78.     supported include a jukebox player (plays lists constantly) as well as
  79.     modules in random order. A demo version is available from me now, and
  80.     will be on next issue's coverdisk. Send SAE and disk for your demo now
  81.     !! You know where the address is.
  82.     
  83. û
  84.         Well, it is time for me to wet the bed, so to speak, so until we
  85.     happen to meet at some point in our lives, it's goodnight to you from
  86.     me and Millie. Chow, dudes and dudettes.
  87.     
  88. ú
  89.     [Andrew "Mushroom" Kellett]
  90.     
  91. ÷
  92. EOF
  93.  
  94.